/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : home.js                                 
*  Description  : 클럽개별메인 
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-06-12  이윤노    Created.  
*  2012-06-14  이윤노    Complete.  
*******************************************************************************/

jQuery(function($){
	
	//최근게시글
	function clsClubBoardList(){
		this._HTMLDom = null;
		this.boardList = null;
		
		this._init();
	}
	
	clsClubBoardList.prototype = {
		_init: function(){
			var $layer = $("div#container section.self_home_board:eq(0) dl.home_board");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("table tbody tr:first")
				, "$empty": $layer.find("article.board_list_none")
			}
			
			$layer.find("tbody").empty();
		}
		, setList: function(thisData){
			this.boardList = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.find("tbody").empty();
			
			if(!this.boardList.length) this._HTMLDom["$empty"].show();
			else this._HTMLDom["$empty"].hide();
			
			for(var i=0;i<this.boardList.length;i++){
				$layer.find("tbody").append($element.clone(true)); 
			}
			
			$layer.find("tr").each(function(n){
				$(this).find("td:eq(0) a").html(_util.leftB(thisClass.boardList[n]["제목"],50) + " <em>("+ getFormatNumber(thisClass.boardList[n]["댓글수"])+")</em>").click(function(event){
					event.preventDefault();
					document.location.href = "club_view.html?club_seq=" + thisClass.boardList[n]["동호회키"] + "&board_seq=" + thisClass.boardList[n]["게시판키"];					
				});
				if(!thisClass.boardList[n]["댓글수"]){
					$(this).find("td:eq(0) a em").remove();
				}
				$(this).find("td:eq(1)").html(getFormatDateYmd(thisClass.boardList[n]["작성일"],"-"));
				$(this).find("td:eq(2)").html(getFormatTime(thisClass.boardList[n]["작성시간"],":"));
			});
					
		}
		// 더보기 버튼
		, $getBtnMore: function(){
			var $layer = this._HTMLDom["$layer"];
			
			return $layer.parent().find("dt span a");
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("table").hide();
			if($layer.find("#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='width:100px; height:100px;'></div>");
			}
			$layer.find("#tmpSpin").spin().show();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("#tmpSpin").spin(false).hide();
			$layer.find("table").show();
		}
		
	}
	
	//최근앨범
	function clsClubAlbumList(){
		this._HTMLDom = null;
		this.albumList = null;
		
		this._init();
	}
	
	clsClubAlbumList.prototype = {
		_init: function(){
			var $layer = $("div#container section.self_home_board:eq(0) dl.home_phto");
			this._HTMLDom = {
				"$layer": $layer.find("dd:eq(1)")
				, "$element": $layer.find("dl:first")
				, "$empty":  $layer.find("dd:eq(0)")
			}
			
			$layer.find("dd:eq(1)").empty();			
		}
		, setList: function(thisData){
			this.albumList = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.empty();
			
			if(!this.albumList.length) this._HTMLDom["$empty"].show();	
			else this._HTMLDom["$empty"].hide();					
			
			for(var i=0;i<this.albumList.length;i++){
				$layer.append($element.clone(true));
			}
			
			$layer.find("dl").each(function(n){
				$(this).find("dt img").attr("src", _gf.filePath2Url(thisClass.albumList[n]["이미지"])); // 이미지
				$(this).find("dd p:eq(0) a").html(_util.leftB(thisClass.albumList[n]["제목"],17)+ " <em>("+ getFormatNumber(thisClass.albumList[n]["댓글수"])+")</em>"); // 제목
				if(!thisClass.albumList[n]["댓글수"]){
					$(this).find("dd p:eq(0) a em").remove();
				}				
				$(this).find("dd p.ph_date span:eq(0)").html(getFormatDateYmd(thisClass.albumList[n]["작성일"],"-")); // 날짜
				$(this).find("dd p.ph_date span:eq(1)").html(getFormatTime(thisClass.albumList[n]["작성시간"],":")); // 시간
				
				$(this).find("a").click(function(event){
					event.preventDefault();
					document.location.href = "club_picture_view.html?club_seq=" + thisClass.albumList[n]["동호회키"] + "&board_seq="+ thisClass.albumList[n]["게시판키"];					
				});
			});
			
		}
		// 더보기 버튼
		, $getBtnMore: function(){
			var $layer = this._HTMLDom["$layer"];
			
			return $layer.parent().find("dt span a");
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.children().hide();
			if($layer.parent().find("#tmpSpin").length == 0){
				$layer.after("<div id='tmpSpin' style='width:100px; height:100px;'></div>");
			}
			$layer.parent().find("#tmpSpin").spin().show();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.parent().find("#tmpSpin").spin(false).hide();
			$layer.children().show();
		}
	}
	
	//핫이슈
	function clsClubHotList(){
		this._HTMLDom = null;
		this.hotList = null;
		
		this._init();		
	}
	
	clsClubHotList.prototype = {
		_init: function(){
			var $layer = $("div#container section.self_home_board:eq(1) dl.home_board:eq(0)");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("table tbody tr:first")
				, "$empty": $layer.find("article.board_list_none")
			}
			
			$layer.find("tbody").empty();
		}
		, setList: function(thisData){
			this.hotList = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"].find("tbody");
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.empty();
			
			if(!this.hotList.length) this._HTMLDom["$empty"].show();
			else this._HTMLDom["$empty"].hide();
			
			for(var i=0;i<this.hotList.length;++i){
				$layer.append($element.clone(true));	
			}
			
			$layer.find("tr").each(function(n){
				$(this).find("td:eq(0) a").contents().filter(function(){
					return (this.nodeType == 3 && this.data.trim())
				}).after(_util.leftB(thisClass.hotList[n]["제목"],50)).remove();
				if(thisClass.hotList[n]["댓글수"]) {
					$(this).find("td:eq(0) a em").html("("+ getFormatNumber(thisClass.hotList[n]["댓글수"])+")");
				}else{
					$(this).find("td:eq(0) a em").remove();
				}
				$(this).find("td:eq(0) a").click(function(event){
					event.preventDefault();
					document.location.href = "club_view.html?club_seq=" + thisClass.hotList[n]["동호회키"] + "&board_seq=" + thisClass.hotList[n]["게시판키"];				
				});
				$(this).find("td:eq(1)").html(getFormatNumber(thisClass.hotList[n]["조회수"]));
				$(this).find("td:eq(2)").html(getFormatDateYmd(thisClass.hotList[n]["작성일"],"-"));
				$(this).find("td:eq(3)").html(getFormatTime(thisClass.hotList[n]["작성시간"],":"));
			});
			
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("table").hide();
			if($layer.find("#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='width:100px; height:100px;'></div>");
			}
			$layer.find("#tmpSpin").spin().show();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("#tmpSpin").spin(false).hide();
			$layer.find("table").show();
		}
	}
	
	//공지사항
	function clsClubNoticeList(){
		this._HTMLDom = null;
		this.noticeList = null
		
		this._init();
	}
	
	clsClubNoticeList.prototype = {
		_init: function(){
			var $layer = $("div#container section.self_home_board:eq(1) dl.home_board:eq(1)");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("table tbody tr:first")	
				, "$empty": $layer.find("article.board_list_none")
			}
			
			$layer.find("tbody").empty();
		}
		, setList: function(thisData){
			this.noticeList = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"].find("tbody");
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.empty();
			
			if(!this.noticeList.length) this._HTMLDom["$empty"].show();
			else this._HTMLDom["$empty"].hide();
			
			for(var i=0;i<this.noticeList.length;++i){
				$layer.append($element.clone(true));	
			}
				
			$layer.find("tr").each(function(n){
				$(this).find("td:eq(0) a").html(_util.leftB(thisClass.noticeList[n]["제목"],50)).click(function(event){
					event.preventDefault();
					document.location.href = "club_view.html?club_seq=" + thisClass.noticeList[n]["동호회키"] + "&board_seq=" + thisClass.noticeList[n]["게시판키"];				
				});
				$(this).find("td:eq(1)").html(getFormatDateYmd(thisClass.noticeList[n]["작성일"],"-"));
				$(this).find("td:eq(2)").html(getFormatTime(thisClass.noticeList[n]["작성시간"],":"));
			});
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("table").hide();
			if($layer.find("#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='width:100px; height:100px;'></div>");
			}
			$layer.find("#tmpSpin").spin().show();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("#tmpSpin").spin(false).hide();
			$layer.find("table").show();
		}
	}
	
	//라운드
	function clsClubScheduleList(){
		this._HTMLDom = null;
		this.roundList = null;	
		this._init();
	}
	
	clsClubScheduleList.prototype = {
		_init: function(){
			var $layer = $("div#container section.self_home_joinroom:eq(0)");
			$layer.find("dd:first td.align_c img").error(function(){
				$(this).attr("src", _gf.getDefaultProfileImage());
			});
			this._HTMLDom = {
				"$layer": $layer.find("dl:eq(0)")
				, "$element": $layer.find("dd:first")
				, "$empty": $layer.find("dl:last").hide()
			}
		}
		, setList: function(thisData){
			this.roundList = thisData;
			this.display();
		}
		, addProfile: function(n, thisData){
			this.roundList[n]["프로필"] = thisData;
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.find("dd").remove();
			
			if(!this.roundList.length){
				this._HTMLDom["$empty"].show();
			}else this._HTMLDom["$empty"].hide();
			
			$layer.find("dd").remove();
			
			this.isNoData();
			
			for(var i=0;i<this.roundList.length;++i){
				$layer.append($element.clone(true));	
			}
			
			$layer.find("dd").each(function(n){
			
				$(this).find("td.time").contents().filter(function(){
					return (this.nodeType==3&&this.data.trim());
				}).after(getFormatDateYmd(thisClass.roundList[n]["라운드일자"],".") + "(" + thisClass.roundList[n]["라운드요일"] + ")").remove();
				$(this).find("td.time span").html(thisClass.roundList[n]["라운드시간"]);
				
				$(this).find("td:eq(1)").html(thisClass.roundList[n]["코스명"]);
				$(this).find("td:eq(2)").html(thisClass.roundList[n]["홀수"] + "H");
				$(this).find("td.align_l:eq(0)").css("cursor", "pointer").html(_util.leftB(thisClass.roundList[n]["라운드명"],48)).click(function(event){
					event.preventDefault();			
					document.objControl.goRoundView(n);
				});
				$(this).find("td:eq(4) strong").html(thisClass.roundList[n]["모집팀수"] + "팀");
				$(this).find("td:eq(4)").contents().filter(function(){
					return (this.nodeType==3&&this.data.trim());
				}).after("("+thisClass.roundList[n]["모집인원수"]+"명)").remove();
				$(this).find("td.align_l span.offer:eq(0)").html(thisClass.roundList[n]["신청인원수"]);
				$(this).find("td.align_l span.offer:eq(1)").html(thisClass.roundList[n]["배정완료수"]);
			
				if(thisClass.roundList[n]["라운딩진행상태"]=="P"){
					$(this).find("td.ing img").attr("src", "../images/btn/btn_ing.png");
				}else if(thisClass.roundList[n]["라운딩진행상태"]=="C"){
					$(this).find("td.ing img").attr("src", "../images/btn/btn_ok.png");
				}else if(thisClass.roundList[n]["라운딩진행상태"]=="D"){
					$(this).find("td.ing img").attr("src", "../images/btn/btn_end.png");
				}
				
			});
			
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("dd").hide();
			if($layer.find("#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='position:absolute; left:500px; top:50px; border:1px solid black;'></div>");
			}
			$layer.find("#tmpSpin").spin().show();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("#tmpSpin").spin(false).hide();
			$layer.find("dd").show();
		}
		, isNoData: function(){
			var $layer = $("div#container section#main_content article.board_list_none");
			if(this.roundList.length<=0) {
				$layer.show();
				$("#idClubRoundListPage").hide();
			}else {
				$layer.hide();
				$("#idClubRoundListPage").show();
			}
		}
	}
	
	//조인룸
	function clsClubJoinroomList(){
		this._HTMLDom = null;
		this.joinroomList = null;
		this.profileData = null;
		this.joinroomIdx = null;
		this._init();
	}
	
	clsClubJoinroomList.prototype = {
		_init: function(){
			var $layer = $("div#container section.self_home_joinroom:eq(1)");
			$layer.find("dd:first td.align_c img").error(function(){
				$(this).attr("src", _gf.getDefaultProfileImage());
			});
			this._HTMLDom = {
				"$layer": $layer.find("dl:eq(0)")
				, "$element": $layer.find("dd:first").clone(true)
				, "$empty": $layer.find("dl:eq(1)")
			}
			
			this.setList([]);
		}
		, setList: function(thisData){
			this.joinroomList = thisData;
			this.profileData = [];
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.find("dd").remove();
			
			if(!this.joinroomList.length){
				this._HTMLDom["$empty"].show();
			}else this._HTMLDom["$empty"].hide();
			
			for(var i=0;i<this.joinroomList.length;i++){
				$layer.append($element.clone(true));
			}
			
			$layer.find("dd").each(function(n){
				$(this).find("td.align_c img").attr("src", thisClass.joinroomList[n]["부킹장정보"]["이미지"]); // 이미지
				$(this).find("td.nickname").html(thisClass.joinroomList[n]["부킹장정보"]["닉네임"]).hover(function(event){
					_gf.showProfileLayer($(this), thisClass.profileData[n], "left", 0, 33);
				}, function(event){
					_gf.closeProfileLayer();
				});				
				$(this).find("td.time").contents().filter(function(){
					return (this.nodeType==3&&this.data.trim())
				}).after(thisClass.joinroomList[n]["일자"]).remove();
				$(this).find("td.time span").html(thisClass.joinroomList[n]["시간"]);
				$(this).find("td.id").html(_util.leftB(thisClass.joinroomList[n]["코스"],40));
				$(this).find("td:eq(4)").html(thisClass.joinroomList[n]["홀수"] + "H");
				if(thisClass.joinroomList[n]["공개유무"]=="Y") $(this).find("td:eq(5) img").hide()
				$(this).find("td.align_l:eq(0)").html(_util.leftB(thisClass.joinroomList[n]["제목"],78)).click(function(event){
					thisClass.joinroomIdx=n;						
					if(thisClass.joinroomList[n]["공개유무"] == "Y"){						
						document.objControl.goViewPage();
					}else {
						var winPasswd = window.open(_ROOT + "/popup/pop_pw.html", "winPasswd", "width=290, height=300, scrollbars=0");
						if(winPasswd) winPasswd.focus();
					}
					
				});
				
				$(this).find("ol.person").empty();
				var cnt = Number(thisClass.joinroomList[n]["초대인원"]);
				for(var m=1;m<=cnt;m++){				
					$(this).find("ol.person").append("<li class='off'>" + (m) + "</li>");
				}
				
				$layer.find("ol.person li").attr("css", "").addClass("off");
			});
			
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("dd").hide();
			if($layer.find("#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='position:absolute; left:100px; top:50px; border:1px solid black;'></div>");
			}
			$layer.find("#tmpSpin").spin().show();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("#tmpSpin").spin(false).hide();
			$layer.find("dd").show();
		}
		, addProfile: function(idx, oneData){
			this.profileData[idx] = oneData;
		}
		, getPasswd: function(n){
			return this.joinroomList[n]["비밀번호"];
		}
		, getKey: function(n){
			return this.joinroomList[n]["조인룸키"];
		}
		, setJoinList: function(key, thisData){
			
			var $layer = this._HTMLDom["$layer"];
			
			var n = key["인덱스"];			
			this.joinroomList[n]["참여자정보"] = thisData;
			
			$layer.find("dd").eq(n).find("ol.person li").filter(":lt(" + thisData.length + ")").removeClass("off").addClass("on");
			
			// 참여자 수에따른 색깔 설정
			$layer.find("dd").eq(n).find("ol.person").hover(function(){					
				if(thisData.length){
					_gf.showMemberLayer($(this), thisData, "left", -20, ($(this).height() || 12));
				}
			}, function(){
				_gf.closeMemberLayer();					
			});
			
		}
		, setApplyList: function(key, thisData){
		
			var $layer = this._HTMLDom["$layer"];
			
			var n = key["인덱스"];			
			this.joinroomList[n]["신청자정보"] = thisData;
			
			$layer.find("td.align_l span").eq(n).html(thisData.length);
			
			
			$layer.find("dd").eq(n).find("td.align_l span").hover(function(){
				if(thisData.length){					
					_gf.showMemberLayer($(this), thisData, "right", -155, ($(this).height() || 12));
				}
			}, function(){
				_gf.closeMemberLayer();					
			});
		}
	}
		
	function clsComm()
	{
		this.club_seq = null;
		this.clubBoardList = null;
		this.clubAlbumList = null;
		this.clubHotList = null;
		this.clubNoticeList = null;		
		this.clubJoinroomList = null;
		this.clubJoinroomListRequest = null;
		this.clubJoinroomListPageData = null;
		this.clubScheduleList = null;
		this.clubScheduleListRequest = null;
		this.clubScheduleListPageData = null;
		
		this._init();
	}
	
	clsComm.prototype = {
		_init: function(){
									
			this.clubJoinroomList = [
				{
					"게시판키": null
					, "글제목": null
					, "작성일": null
					, "작성시간": null				
					, "댓글수": null
					, "일자": null
					, "진행상황": null
					, "골프장명": null
					, "골프장코스": null
					, "노출여부": null
					, "홀정보": null
					, "참여인원": null
					, "신청인원": null
					, "닉네임": null
					, "이미지": null				
				}
			];
			
			this.clubJoinroomListRequest = {
				"페이지":null	
				, "동호회키": null
			}
			
			this.clubJoinroomListPageData = {
				"전체수": null	
			}
			
			this.clubScheduleListRequest = {
				 "동호회키":null
				, "라운드키": null
				, "페이지": null				
			}
			
			this.clubScheduleListPageData = {
				"전체수": null	
			}
		}
		, setClubSeq : function(key){
			this.club_seq = key;	
		}
//------------------------ 최근게시글---------------------------//				
		, getClubBoardList: function(){
			var thisClass = this;
			var szClubSeq = this.club_seq;
		
			// ajax 시작			 
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"getClubBoardList",
				"listcount":5,
				"currpageno":1
			}, {
				 "club_seq": szClubSeq
				, "board_type": "D"
			}, function(ret){
				
				// callback and mapping
				thisClass.clubBoardList = [];
			
				if(ret["msp"]["contents"]["items"]){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"]	= new Array(ret["msp"]["contents"]["items"]);
					}
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						thisClass.clubBoardList.push({
							"동호회키": _util.nvl(obj["club__seq"])
							, "게시판키": _util.nvl(obj["board__seq"])
							, "이미지": _util.nvl(obj["filepath"])
							, "제목": _util.nvl(obj["title"])
							, "댓글수": _util.nvl(obj["cr__cnt"])
							, "조회수": _util.nvl(obj["hit"])
							, "나이스샷": _util.nvl(obj["niceshot"])
							, "작성일": _util.nvl(obj["reg__date"])
							, "작성시간": _util.nvl(obj["reg__time"])
						});
					}
				}
				
				$(thisClass).trigger("evtFinishClubBoardList");
			});
			// ajax 끝
			
		}
		, getClubBoardListData: function(){
			return this.clubBoardList;
		}
//------------------------ 최근게시글---------------------------//
//------------------------ 최근앨범-----------------------------//
		, getClubAlbumList: function(){
			var thisClass = this;
			var szClubSeq = this.club_seq;
						
			// ajax 시작			 
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"getClubBoardList",
				"listcount":3,
				"currpageno":1
			}, {
				 "club_seq": szClubSeq
				, "board_type": "P"
			}, function(ret){
				
				// callback and mapping
				thisClass.clubAlbumList = [];
			
				if(ret["msp"]["contents"]["items"]){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"]	= new Array(ret["msp"]["contents"]["items"]);
					}
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						thisClass.clubAlbumList.push({
							"동호회키": _util.nvl(obj["club__seq"])
							, "게시판키": _util.nvl(obj["board__seq"])
							, "이미지": _util.nvl(obj["filepath"])
							, "제목": _util.nvl(obj["title"])
							, "댓글수": _util.nvl(obj["cr__cnt"])
							, "조회수": _util.nvl(obj["hit"])
							, "나이스샷": _util.nvl(obj["niceshot"])
							, "작성일": _util.nvl(obj["reg__date"])
							, "작성시간": _util.nvl(obj["reg__time"])
						});
					}
				}
				
				$(thisClass).trigger("evtFinishClubAlbumList");
			});
			// ajax 끝			
			
		}
		, getClubAlbumListData: function(){
			return this.clubAlbumList;
		}
//------------------------ 최근앨범-----------------------------//
//------------------------ 핫이슈-------------------------------//
		, getClubHotList: function(){
			var thisClass = this;
			var szClubSeq = this.club_seq;
			
			// ajax 시작			 
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"getClubBoardList",
				"listcount":5,
				"currpageno":1
			}, {
				 "club_seq": szClubSeq
				, "main_yn": "Y"
				, "view_type": "A"
//				, "file_seq_attach": ""
			}, function(ret){
				
				// callback and mapping
				thisClass.clubHotList = [];
			
				if(ret["msp"]["contents"]["items"]){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"]	= new Array(ret["msp"]["contents"]["items"]);
					}
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						thisClass.clubHotList.push({
							"동호회키": _util.nvl(obj["club__seq"])
							, "게시판키": _util.nvl(obj["board__seq"])
							, "이미지": _util.nvl(obj["filepath"])
							, "제목": _util.nvl(obj["title"])
							, "댓글수": _util.nvl(obj["cr__cnt"])
							, "조회수": _util.nvl(obj["hit"])
							, "나이스샷": _util.nvl(obj["niceshot"])
							, "작성일": _util.nvl(obj["reg__date"])
							, "작성시간": _util.nvl(obj["reg__time"])	
						});
					}
				}
				
				$(thisClass).trigger("evtFinishClubHotList");
			});
			// ajax 끝		
			
		}
		, getClubHotListData: function(){
			return this.clubHotList;
		}
//------------------------ 핫이슈-------------------------------//
//------------------------ 공지사항-----------------------------//
		, getClubNoticeList: function(){
			var thisClass = this;
			var szClubSeq = this.club_seq;
						
			// ajax 시작			 
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"getClubBoardList",
				"listcount":5,
				"currpageno":1
			}, {
				 "club_seq": szClubSeq
				, "notice_yn": "Y"
			}, function(ret){
				
				// callback and mapping
				thisClass.clubNoticeList = [];
			
				if(ret["msp"]["contents"]["items"]){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"]	= new Array(ret["msp"]["contents"]["items"]);
					}
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						thisClass.clubNoticeList.push({
							"동호회키": _util.nvl(obj["club__seq"])
							, "게시판키": _util.nvl(obj["board__seq"])
							, "이미지": _util.nvl(obj["filepath"])
							, "제목": _util.nvl(obj["title"])
							, "댓글수": _util.nvl(obj["cr__cnt"])
							, "조회수": _util.nvl(obj["hit"])
							, "나이스샷": _util.nvl(obj["niceshot"])
							, "작성일": _util.nvl(obj["reg__date"])
							, "작성시간": _util.nvl(obj["reg__time"])			
						});
					}
				}
				
				$(thisClass).trigger("evtFinishClubNoticeList");
			});
			// ajax 끝			
			
		}
		, getClubNoticeListData: function(){
			return this.clubNoticeList;
		}
//------------------------ 공지사항-----------------------------//
//------------------------ 조인룸-------------------------------//
		, getClubJoinroomList: function(){
			var thisClass = this;
			var szClubSeq = this.club_seq;
			var szPage = this.clubJoinroomListRequest["페이지"];
			
			// ajax 시작			 
			//parameter setting and run
			_gf.ajax({
				"sid":"JR001",
				"servicename":"getClubJoinRoomList",
				"listcount":5,
				"currpageno":szPage
			}, {
				 "clubSeq": szClubSeq
			}, function(ret){
				
				// callback and mapping
				thisClass.clubJoinroomListPageData = {
						"전체수": ret["msp"]["contents"]["@totalcount"]
				}
				
				var items = ret["msp"]["contents"]["items"];
				
				thisClass.clubJoinroomList = [];
			
				if(items){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"]	= new Array(ret["msp"]["contents"]["items"]);
					}
					
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						thisClass.clubJoinroomList.push({
							"조인룸키": _util.nvl(obj["joinRoomSeq"])
							, "부킹장정보": {
								"아이디": _util.nvl(obj["bookingId"])
								, "닉네임": _util.nvl(obj["nickName"])
								, "이미지": _gf.filePath2Url(_util.nvl(obj["path"]) + _util.nvl(obj["saveFileNm"]))
							}
							, "회원아이디": _util.nvl(obj["participantId"])
							, "비밀번호": _util.nvl(obj["password"])
							, "일자": _util.nvl(obj["reserveDate"])
							, "시간": _util.nvl(obj["bookingTime"])							
							, "코스": _util.nvl(obj["golfClubInfo"])
							, "홀수": _util.nvl(obj["holeInfo"])
							, "공개유무": _util.nvl(obj["openYn"])
							, "제목": _util.nvl(obj["ment"])
							, "참여인원": _util.nvl(obj["particnt"])
							, "참여자정보": []
							, "신청인원": _util.nvl(obj["applycnt"])
							, "신청자정보": []
							, "초대인원":  _util.nvl(obj["invitCnt"], 0)
						});					
					}					
				}				
				
				$(thisClass).trigger("evtFinishClubJoinroomList");
			});
			// ajax 끝			
		}
		, getClubJoinroomListData: function(){
			return this.clubJoinroomList;
		}
		, getClubJoinroomListPageData: function(){
			return this.clubJoinroomListPageData;
		}
		, setClubJoinroomListRequest: function(key, val){
			this.clubJoinroomListRequest[key] = val;
		}
		, getClubJoinroomListRequest: function(key){
			return this.clubJoinroomListRequest[key];
		}	// 참여자
		, getJoinList: function(arg){
			var thisClass = this;
			
			//ajax
			document.objGlobal.ajax({
				"sid":"JR001",
				"servicename":"getMemberList",
				"listcount":10,
				"currpageno":1
			}, {
				"joinRoomSeq": arg["조인룸키"]
			}, function(ret){
				var aList = [];
				
				if(ret["msp"]["contents"]["items"]){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"]	= new Array(ret["msp"]["contents"]["items"]);
					}

					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						aList.push({
							"아이디": _util.nvl(obj["participantId"])
							, "닉네임": _util.nvl(obj["nickName"])
							, "이미지": _util.nvl(obj["path"]) + _util.nvl(obj["saveFileNm"])
						});
					}					
				}
				
				document.objControl.finishJoinList(arg, aList);
			});
		}
		// 신청자
		, getApplyList: function(arg){
			var thisClass = this;
		
			//ajax
			document.objGlobal.ajax({
				"sid":"JR001",
				"servicename":"getApplyMemberList",
				"listcount":10,
				"currpageno":1
			}, {
				"joinRoomSeq": arg["조인룸키"]
			}, function(ret){
				var aList = [];
				
				if(ret["msp"]["contents"]["items"]){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"]	= new Array(ret["msp"]["contents"]["items"]);
					}
					
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						aList.push({
							"아이디": _util.nvl(obj["participantId"])
							, "닉네임": _util.nvl(obj["nickName"])
							, "이미지": _util.nvl(obj["path"]) + _util.nvl(obj["saveFileNm"])
						});
					}					
				}
				document.objControl.finishApplyList(arg, aList);
			});
		}
//------------------------ 조인룸-------------------------------//
//------------------------ 라운드목록------------------------//		
		, getClubScheduleList: function(){
			var thisClass = this;
			var szClubSeq = this.club_seq;
			var szPage = this.clubScheduleListRequest["페이지"];
			var szClosedRoundDispYn = "N";
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename":"getClubRoundList",
				"listcount":5,
				"currpageno":szPage
			}, {
				  "clubSeq": szClubSeq
				  , "closedRoundDispYn": szClosedRoundDispYn
			}, function(ret){
				
				// callback and mapping
				thisClass.clubScheduleList = [];
			
				if(ret["msp"]["contents"]["items"]){					
					thisClass.clubScheduleListPageData = {
						"전체수": ret["msp"]["contents"]["@totalcount"]
					}
					
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"] = new Array(ret["msp"]["contents"]["items"]);
					}
					
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						
						//동호회목록
						thisClass.clubScheduleList.push({
							"동호회키": _util.nvl(obj["roundInfo"]["clubSeq"])
							, "아이디": _util.nvl(obj["userMaster"]["userId"])
							, "닉네임": _util.nvl(obj["userMaster"]["nickname"])
							, "라운드키": _util.nvl(obj["roundInfo"]["roundSeq"])
							, "라운드일자": _util.nvl(obj["roundInfo"]["reservDate"])
							, "라운드요일": _util.nvl(obj["roundInfo"]["reservDay"])
							, "라운드시간": _util.nvl(obj["roundInfo"]["firstTime"])
							, "코스명": _util.nvl(obj["roundInfo"]["golfclubCourseInfo"])
							, "홀수": _util.nvl(obj["roundInfo"]["holeInfo"])
							, "라운드명": _util.nvl(obj["roundInfo"]["title"])
							, "모집팀수": _util.nvl(obj["roundInfo"]["totalTeamCnt"])
							, "모집인원수": _util.nvl(obj["roundInfo"]["totalMember"])
							, "신청인원수": _util.nvl(obj["roundInfo"]["requestedMemberCnt"])
							, "배정완료수": _util.nvl(obj["roundInfo"]["assignedMemberCnt"])
							, "라운딩진행상태": _util.nvl(obj["roundInfo"]["procStatus"]) //진행중(P),확정(C),마감(D)					
							, "프로필": []								
						});
					}         
				}
				
				$(thisClass).trigger("evtFinishClubScheduleList");
			});
		}
		, getClubScheduleListData: function(){
			return this.clubScheduleList;
		}
		, getClubScheduleListPageData: function(){
			return this.clubScheduleListPageData;
		}
		, setClubScheduleListRequest: function(key, val){
			this.clubScheduleListRequest[key] = val;
		}
//------------------------ 라운드목록------------------------//	
	}
	
	function clsControl()
	{
		this.club_seq = null;
		
		this.objComm = null;				
		this.objClubInfo = null;
		this.objRole = null;
		this.objClubBoardList = null;
		this.objClubAlbumList = null;
		this.objClubHotList = null;
		this.objClubNoticeList = null;		
		this.objClubJoinroomList = null;
		this.objClubJoinroomListPage = null;
		this.objClubScheduleList = null;
		this.objClubScheduleListPage = null;
		
		this._permitStart = null;
		
		this._init();
	}
	
	clsControl.prototype = {
		_init: function(){			
			
			this.club_seq = _util.getParam("club_seq");
			var member_id = _util.getCookie("member_id");
			
			if(!member_id) {
				/*
				if(confirm("로그인 후 이용하여 주세요.")){
					_gf.goLogin();						
				}else{
					document.location.href = "../club/club.html";
				}
				*/
			}
			
			this._preload();
			
			this.objComm = new clsComm();			
			this.objClubBoardList = new clsClubBoardList();
			this.objClubAlbumList = new clsClubAlbumList();
			this.objClubHotList = new clsClubHotList();
			this.objClubNoticeList = new clsClubNoticeList();			
			this.objClubJoinroomList = new clsClubJoinroomList();
			this.objClubJoinroomListPage = new _gf.makeTinyPaging($("#idJoinroomPage"), 5);
			this.objClubScheduleList = new clsClubScheduleList();
			this.objClubScheduleListPage = new _gf.makeTinyPaging($("#idSchedulePage"), 5);
			
			this._beforeStart();
			this._bind();
		}
		, _preload: function(){
			_gf.spinStart();
		}
		, _beforeStart: function(){
			var thisClass = this;
			this._permitStart = {
				
			}
			
			$.ajax({
				url: "js/self_club_top.js"
				, dataType: "script"
				, async: false
				, success: function(){
					
				}
				, error: function(){
					alert("error");
				}
			});
			
			_util.executeThread(function(){
				for(var k in thisClass._permitStart){
					if(!thisClass._permitStart[k]) return false;
				}
				
				return (_clubControl.getClubInfo().infoData);
			}, function(){				
				_gf.spinEnd();;
				thisClass._start();
			});	
		}
		, _role: function(){
			
		}
		, _start: function(){		
			this.objClubInfo = _clubControl.getClubInfo();
			this.objRole = new clsRole(this.objClubInfo.infoData);
			this._role();
			
			this.objComm.setClubSeq(this.objClubInfo.infoData["동호회키"]);
			
			//최글게시글 조회
			this.objClubBoardList.spinStart();
			this.objComm.getClubBoardList();
			
			//최글앨범 조회
			this.objClubAlbumList.spinStart();
			this.objComm.getClubAlbumList();
			
			//동호회 핫이슈
			this.objClubHotList.spinStart();
			this.objComm.getClubHotList();
			
			//동호회 공지
			this.objClubNoticeList.spinStart();
			this.objComm.getClubNoticeList();
			
			//동호회 조인룸
			this.objClubJoinroomList.spinStart();
			this.objClubJoinroomListPage.setPage(1);
			this.objComm.setClubJoinroomListRequest("페이지",1);			
			this.objComm.getClubJoinroomList();
			
			//라운드
			this.objClubScheduleList.spinStart();
			this.objClubScheduleListPage.setPage(1);
			this.objComm.setClubScheduleListRequest("페이지",1);						
			this.objComm.getClubScheduleList();
		}
		, _bind: function(){
			var thisClass = this;
			
			// 나의동호회 리스트
			$(this.objComm).bind("evtFinishClubMyList", function(){
				var thisData = thisClass.objComm.getClubMyListData();
				thisClass.objClubMyList.setList(thisData);				
			});
			
			// 최근게시글 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubBoardList", function(){
				var thisData = thisClass.objComm.getClubBoardListData();
				thisClass.objClubBoardList.setList(thisData);
				thisClass.objClubBoardList.spinEnd();
			});
			// 최근앨범 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubAlbumList", function(){
				var thisData = thisClass.objComm.getClubAlbumListData();
				thisClass.objClubAlbumList.setList(thisData);
				thisClass.objClubAlbumList.spinEnd();
			});
			// 동호회핫이슈 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubHotList", function(){
				var thisData = thisClass.objComm.getClubHotListData();
				thisClass.objClubHotList.setList(thisData);
				thisClass.objClubHotList.spinEnd();
			});
			// 동호회공지 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubNoticeList", function(){
				var thisData = thisClass.objComm.getClubNoticeListData();
				thisClass.objClubNoticeList.setList(thisData);
				thisClass.objClubNoticeList.spinEnd();
			});
			//동호회 글목록조회  완료 이벤트 
			$(this.objComm).bind("evtFinishClubScheduleList", function(){
				var thisData = thisClass.objComm.getClubScheduleListData()
				var pageData = thisClass.objComm.getClubScheduleListPageData();
				
				thisClass.objClubScheduleList.spinEnd();
				thisClass.objClubScheduleList.setList(thisData);
				
				// 페이지 부에 전체 수설정 				
				thisClass.objClubScheduleListPage.setTotalCount(pageData["전체수"]);
				thisClass.objClubScheduleListPage.display();
				
				//프로필
				for(var i=0;i<thisData.length;++i){									
					_gf.getMemberInfo({
						"아이디": thisData[i]["아이디"]
						, "인덱스": i
						, "콜백": function(res, info, arg){
							thisClass.objClubScheduleList.addProfile(arg["인덱스"], info);
						}
					});
				}
			});
			
			// 페이지이동 이벤트
			$(this.objClubScheduleListPage).bind("evtPageClick", function(){
				var thisPage = this.getPage();
				
				thisClass.objComm.setClubScheduleListRequest("페이지", thisPage);
				thisClass.objClubScheduleList.spinStart();
				thisClass.objComm.getClubScheduleList();
			});
			// 동호회조인룸 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubJoinroomList", function(){
				var thisData = thisClass.objComm.getClubJoinroomListData();
				var pageData = thisClass.objComm.getClubJoinroomListPageData();
				
				thisClass.objClubJoinroomList.setList(thisData);
				thisClass.objClubJoinroomList.spinEnd();
				
				// 페이지 부에 전체 수설정 
				if(pageData["전체수"]-0){
					thisClass.objClubJoinroomListPage.$getLayer().show();
					thisClass.objClubJoinroomListPage.setTotalCount(pageData["전체수"]);
					thisClass.objClubJoinroomListPage.display();
				}else{
					thisClass.objClubJoinroomListPage.$getLayer().hide();
				}
				
				for(var i=0;i<thisData.length;++i){					
					_gf.getMemberInfo({
						"아이디": thisData[i]["부킹장정보"]["아이디"]
						, "인덱스": i
						, "콜백": function(res, info, arg){
							thisClass.objClubJoinroomList.addProfile(arg["인덱스"], info);
						}
					});
					
					// 참여자
					thisClass.objComm.getJoinList({
						"조인룸키": thisData[i]["조인룸키"]
						, "인덱스": i
					});
				
					// 신청자
					thisClass.objComm.getApplyList({
						"조인룸키": thisData[i]["조인룸키"]
						, "인덱스": i
					});				
				}				
			
			});			
						
			// 페이지이동
			$(this.objClubJoinroomListPage).bind("evtPageClick", function(){
				var thisPage = this.getPage();
				
				thisClass.objClubJoinroomList.spinStart();
				thisClass.objComm.setClubJoinroomListRequest("페이지", thisPage);
				thisClass.objComm.getClubJoinroomList();
			});
			
			// 최근자유게시글 더보기버튼 이벤트
			this.objClubBoardList.$getBtnMore().click(function(event){
				event.preventDefault();						
				document.location.href = "club_list.html?club_seq="  + thisClass.club_seq;	
			});
			
			// 최근앨범게시글 더보기버튼 이벤트
			this.objClubAlbumList.$getBtnMore().click(function(event){
				event.preventDefault();						
				document.location.href = "club_picture_list.html?club_seq="  + thisClass.club_seq;	
			});
			
		}
		// 상세페이지 이동
		, goViewPage: function(w){
			if(w) w.close();			
			_util.setCookie("joinroomKey", this.objClubJoinroomList.getKey(this.objClubJoinroomList.joinroomIdx), null, "/");			
			var params = {
				"q_seq": this.objClubJoinroomList.getKey(this.objClubJoinroomList.joinroomIdx)
			}
			
			var szLink = _ROOT + "/booking/join_room_view01.html" + _util.object2paramString(params);
			var a = document.createElement("A");
			$(a).attr({
				"href": szLink
				, "target": "_self"
				, "id": "idPermissionLink"
			}).appendTo($("body"));
			a.click();
			$(a).remove();
			//document.location.href = _ROOT + "/booking/join_room_view01.html" + _util.object2paramString(params);
		}
		// 비밀번호 
		, getPasswd: function(){
			return this.objClubJoinroomList.getPasswd(this.objClubJoinroomList.joinroomIdx);
		}
		// 참여자 조회 완료이벤트
		, finishJoinList: function(key, listData){
			this.objClubJoinroomList.setJoinList(key, listData);
		}
		// 신청자 조회 완료이벤트
		, finishApplyList: function(key, listData){
			this.objClubJoinroomList.setApplyList(key, listData);
		}
		//라운드 상세보기
		, goRoundView: function(n){
			document.location.href = "club_admin_rd.html?club_seq="+ this.club_seq + "&round_seq=" + this.objClubScheduleList.roundList[n]["라운드키"];
		}
	}
	
	document.objControl = new clsControl();
});